//发货单登记详情（零担）

interface IOrderRegisterBreakViewModel extends ng.IScope {
    /**
     * 承运单详情
     */
    carrierOrderData: invoiceManagement;
    /**
     * 订单列表
     */
    orderList: Array<invoiceManagementOrder>;
    /**
     * 订单数据
     */
    orderData: invoiceManagementOrder;
    /**
     * 子单列表
     */
    orderChildList: Array<invoiceManagementOrderChild>;
    /**
     * 子单数据
     */
    orderChildData: invoiceManagementOrderChild;
    /**
     * 合同数据
     */
    contractData: invoiceManagementContract;
    /**
     * 合同编号
     */
    contractId: string;
    /**
     * 合同短号
     */
    contractNumber: string;
    /**
     * 合同货物数量
     */
    contractGoodsNum: number;
    /**
     * 合同货物数量单位
     */
    contractGoodsNumUnit: string;
    /**
     * 合同日期
     */
    contractTime: string;
    /**
     * 合同状态
     */
    contractStatus: string;
    /**
     * 油卡状态
     */
    oilCardStatus: string;
    /**
     * 油卡卡号
     */
    oilCardNum: string;
    /**
     * 收货人
     */
    contractConsignee: string;
    /**
     * 收货人号码
     */
    contractConsigneePhone: string;
    /**
     * 辅助工具
     */
    auxiliaryTool: string;
    /**
     * 发动机号
     */
    engineNumber: string;
    /**
     * 车架号
     */
    frameNumber: string;
    /**
     * 挂车号
     */
    trailerNumber: string;
    /**
     * 挂车车架号
     */
    trailerFrameNumber: string;
    /**
     * 驾驶证
     */
    driverLicenseNumber: string;
    /**
     * 备用电话
     */
    altermatePhone: string;
    /**
     * 承运单备注
     */
    remarks: string;
    /**
     * 货已送达时间
     */
    arrivalTime: string;
    /**
     * 查看详情
     */
    orderDetail: (item: invoiceManagementOrder) => void;
    /**
     * 获取子单数据
     */
    getOrderChildData: (item: invoiceManagementOrderChild) => void;
    /**
     * 定位
     */
    location: (carId: string, driverPhone: string) => void;
    /**
     * 车辆id
     */
    carId: string;
    /**
    *车牌号
    */
    carCode: string;
    /**
    *手机号
    */
    phoneNumber: string;
    /**
    *历史定位地点
    */
    areaS: string;
    /**
    *历史定位时间
    */
    creationTimeS: string;
    /**
    *定位注册按钮启用禁用
    */
    isdisabled1: boolean;
    /**
    *定位按钮启用禁用
    */
    isdisabled2: boolean;
    /**
     * 已发货按钮显示隐藏
     */
    registerBtnF: boolean;
    /**
     * 已发货事件
     */
    delivered: () => void;
    /**
     * 退回派车按钮显示隐藏
     */
    registerBackBtn: boolean;
    /**
     * 退回派车事件
     */
    returnOrderC: () => void;
    /**
     * 货已送达按钮显示隐藏
     */
    registerBtnT: boolean;
    /**
     * 货已送达事件
     */
    Save: () => void;
    /**
     * 确定按钮显示隐藏
     */
    saveBtn: boolean;
    /**
     * 确定按钮启用禁用
     */
    saveDis: boolean;
    /**
      * 电子合同按钮是否启用
      */
    contractT: boolean;
    /**
    * 是否启用发送
    */
    isSend: boolean;
    /**
     * 是否启用撤销合同按钮
     */
    Ecancel: boolean;
    /**
     * 是否显示等待司机签字
     */
    waitSign: boolean;
    /**
     * 客服签章
     */
    kfSeal: boolean;
    /**
 * 是否启用申请补充协议按钮
 */
    applyAgreement: boolean;
    /**
     * 申请补充协议
     */
    isapplyAgreement: () => void;

    /**
   * 是否启用发送
   */
    isASend: boolean;
    /**
     * 是否启用撤销合同按钮
     */
    EAcancel: boolean;
    /**
     * 是否显示等待司机签字
     */
    waitASign: boolean;
    /**
     * 客服签章
     */
    kfASeal: boolean;

    /**
     * 是否显示电子合同
     */
    isContractO: boolean;
    /**
     * 是否显示补充协议
     */
    isAgreementO: boolean;
    /**
     * 是否显示切换补充协议TAB
     */
    isAgreementF: boolean;
    /**
     * 点击显示电子合同
     */
    ContractO: () => void;
    /**
     * 点击显示补充协议
     */
    AgreementO: () => void;
    /**
     * 关闭合同信息弹窗
     */
    EAclose: () => void;
    /**
   * 输入纯数字验证
   */
    patte: (contractNumber) => void;
    /**
     * 电子合同第一张图
     */
    contractImgA: string;
    /**
     * 电子合同第二张图
     */
    contractImgB: string;
    /**
     * 电子合同第三张图
     */
    contractImgC: string;
    /**
     * 电子合同类型
     */
    eContractType: string;
    /**
     * 电子合同状态
     */
    eContractStatus: string;
    /**
  * 电子合同编号
  */
    electronicContractNumber: string;
    /**
     * 电子合同状态
     */
    electronicContractStatus: string;
    /**
     * 补充协议合同编号
     */
    agreementContractNumber: string;
    /**
     * 补充协议合同状态
     */
    agreementContractStatus: string;
    /**
    * 补充协议第一张图
    */
    agreementImgA: string;
    /**
     * 补充协议第二张图
     */
    agreementImgB: string;
    /**
     * 补充协议第三张图
     */
    agreementImgC: string;
    /**
     * 确定事件
     */
    registerSave: () => void;
    /**
     * 生成合同号事件
     */
    contractSave: () => void;
    /**
     * 同步车厂事件
     */
    syncAttachment: () => void;
    /**
     * 查看电子合同详情
    */
    EContractDetail: () => void;
    /**
     * 弹出电子合同
     */
    showEContract: () => void;
    /**
     * 获取电子合同最新状态
     */
    getEContract: () => void;
    /**
    * 发送电子合同
   */
    contractSend: () => void;
    /**
    * 撤销电子合同
   */
    contractRescind: () => void;
    /**
    * 清空合同信息
    */
    clearContractF: () => void;
    /**
    * 创建电子合同
    */
    CreatEcontract: () => void;
    /**
     * 自动计算运费总价
     */
    sumToatlprics: () => void;
    /**
 * 客服签章
 */
    contractSeal: () => void;
    /**
    * 发送补充协议
   */
    AgreementSend: () => void;
    /**
    * 撤销补充协议
   */
    AgreementRescind: () => void;
    /**
     * 客服签章补充协议
     */
    AgreementSeal: () => void;
    /**
     * 切换TAB补充协议
     */
    showEAgreement: () => void;
    /**
     * 取消事件
     */
    skipManage: () => void;
    /**
     * 合同货物数量单位下拉
     */
    goodsNumUnitList: any;
    /**
     * 油卡状态下拉
     */
    oilCardStatusList: any;
    /**
     * 驾驶证上传组件
     */
    driverUploader: any;
    /**
     * 挂车证上传组件
     */
    trailerUploader: any;
    /**
     * 行驶证上传组件
     */
    travelUploader: any;
    /**
     * 身份证上传组件
     */
    idCardUploader: any;
    /**
     * 车辆照片
     */
    carPicUploader: any;
        /**
     * 道路运输证
     */
    roadTransportCardUploader:any
    /**
     * 道路运输经营许可证
     */
    roadTransportLicenseUploader:any;
    /**
     * 从业资格证
     */
    occupationalLicenseUploader:any;
    /**
     * 磅单照片
     */
    weightNoteUploader:any;
    /**
     * 备注启用禁用
     */
    deliveryBtn: boolean;
    /**
     * 客服专员id
     */
    customerServiceOfficerId: string;
    /**
     * 客服专员列表
     */
    customerServiceOfficerList: EmployeeListItemResponse[];
    /**
     * 变换调度员
     */
    changeDispatch: (id: string) => void;
    /**
     * 变换调度是否可用
     */
    registerDis: boolean;
    /**
     * 订单附件
     */
    orderUploader: any;
    /**
     * 回单状态
     */
    receiptType: string;
    /**
     * 回单状态下拉
     */
    receiptStatusList: any;
    /**
   * 回单状态集合（key为订单ID,value为回单状态的枚举）
   */
    receiptState: Array<any>;
    /**
     * 是否自动生成合同号
     */
    isAutoCreate: boolean;
    /**
     * 运费总价
     */
    totalPrice: number;
    /**
    * 送货单号
    */
    deliveryNumber: string;
    /**
     * 保存回单状态
     */
    SaveReceipts: () => void;

    ////////////////////////////////////////

    /**
    *送货地址
    */
    deliverAddress: string;
    deliverAddress_?: string

    /**
    *发货时间
    */
    shipAddress: string;
    shipAddress_: string;

    /**
     * 清除货已送达时间
     */
    clearTime: () => void;
    contractFrom: any;

    /**
     * 点击图片时候触发，用以旋转放大图片
     */
    handleImgClick: (item: any) => void;
    /**
     * 用以旋转放大的图片的路径
     */
    selectedImgSrc: string;

    /**
     * 绑定定位器编号按钮禁用
     */
    forbidBindLocTool: boolean;
    /**
     * 定位器编号
     */
    locToolCode: string;
    /**
     * 绑定定位器编号
     */
    bindLocToolCode: () => void;
    /**
     * 通过定位器定位
     */
    locateByTool: () => void;
    /**
     * 当前选中的订单的id
     */
    selectedOrderId: string;
    /**
     * 是否显示定位器定位的modal
     */
    showLcoToolMdal: boolean;
    /**
     * 承运单Id
     */
    guId: string;
    /**
     * 定位器定位的返回按钮
     */
    lt_back: () => void;
    /**
     * 订单是否绑定到定位器
     */
    orderBinded: boolean;

    /**
    * 绑定失败的提示
    */
    bindFailed: boolean;
    // 绑定成功的提示
    bindSucced: boolean;

    attachList:OssUploaderItem[];
}

class OrderRegisterBreakController {
    /**
     * 承运单附件
     */
    uploaderList: AddCarAttachmentDetail[] = [];
    /**
     * 订单附件
     */
    orderAttachList: AddCarAttachmentDetail[] = [];
    baseImageUrl: string;
    carId: string;

    /**
     * 承运单id
     */
    guId: string;
    /**
     * 合同编号
     */
    contractId: string;
    /**
     * 合同状态
     */
    contractStatus: string;
    /**
     * 订单状态
     */
    type: string;

    constructor(private $scope: IOrderRegisterBreakViewModel, private routeService: routeService, private locationService: ILocationService, private orderService: IorderService,
        private valueService: IValueService, private feeService: IFeeService, private employeeService: IEmployeeService, private $stateParams: any, private $http: ng.IHttpService,
         private $state: angular.ui.IStateService, private $ngBootbox: BootboxService, private $location: ng.ILocationService, private commonService: ICommonService,private ossUploaderService:ossUploaderService) {
        this.baseImageUrl = this.routeService.getBaseUrl() + "attachment/";
        this.init();
    }


    init(): void {
        this.guId = this.$location.search().id;
        this.contractStatus = this.$location.search().contractStatus;
        this.carId = this.$location.search().carId;
        this.type = this.$location.search().type;

        this.$scope.orderDetail = this.orderDetail;
        this.$scope.location = this.location;
        this.$scope.delivered = this.delivered;
        this.$scope.returnOrderC = this.returnOrderC;
        this.$scope.Save = this.Save;
        this.$scope.registerSave = this.registerSave;
        this.$scope.syncAttachment = this.syncAttachment;
        this.$scope.EContractDetail = this.EContractDetail;
        this.$scope.contractSend = this.contractSend;
        this.$scope.contractRescind = this.contractRescind;
        this.$scope.clearContractF = this.clearContractF;
        this.$scope.CreatEcontract = this.CreatEcontract;
        this.$scope.contractSave = this.contractSave;
        this.$scope.skipManage = this.skipManage;
        this.$scope.showEContract = this.showEContract;
        this.$scope.registerBtnF = false;
        this.$scope.registerBtnT = false;
        this.$scope.registerBackBtn = true;
        this.$scope.saveBtn = true;
        this.$scope.saveDis = false;
        this.$scope.contractT = false;
        this.$scope.AgreementO = this.AgreementO;
        this.$scope.EAclose = this.EAclose;
        this.$scope.ContractO = this.ContractO;
        this.$scope.contractSeal = this.contractSeal;
        this.$scope.isapplyAgreement = this.isapplyAgreement;
        this.$scope.AgreementSend = this.AgreementSend;
        this.$scope.AgreementRescind = this.AgreementRescind;
        this.$scope.AgreementSeal = this.AgreementSeal;
        this.$scope.showEAgreement = this.showEAgreement;
        this.$scope.getEContract = this.getEContract;
        this.$scope.patte = this.patte;
        this.$scope.isSend = false;
        this.$scope.Ecancel = false;
        this.$scope.waitSign = false;
        this.$scope.kfSeal = false;
        this.$scope.applyAgreement = false;
        this.$scope.isASend = false;
        this.$scope.EAcancel = false;
        this.$scope.waitASign = false;
        this.$scope.kfASeal = false;
        this.$scope.isContractO = true;
        this.$scope.isAgreementO = false;
        this.$scope.isAgreementF = false;
        this.$scope.clearTime = this.clearTime;
        this.$scope.sumToatlprics = this.sumToatlprics;
        this.$scope.$on("WildDog:Econtract", this.onWilddogEcontractEvent);


     

        const OssFile = this.ossUploaderService.getOssFile();
        this.$scope.attachList=[
            {
                title:'驾驶证',
                uploader:null,
                uploaderName:'driverUploader'
            },{
                title:'挂车证',
                uploader:null,
                uploaderName:'trailerUploader'
            },{
                title:'行驶证',
                uploader:null,
                uploaderName:'travelUploader'
            },{
                title:'身份证',
                uploader:null,
                uploaderName:'idCardUploader'
            },{
                title:'车辆照片',
                uploader:null,
                uploaderName:'carPicUploader'
            },{
                title:'道路运输证',
                uploader:null,
                uploaderName:'roadTransportCardUploader'
            },{
                title:'道路运输经营许可证',
                uploader:null,
                uploaderName:'roadTransportLicenseUploader'
            },{
                title:'从业资格证',
                uploader:null,
                uploaderName:'occupationalLicenseUploader'
            },{
                title:'磅单照片',
                uploader:null,
                uploaderName:'weightNoteUploader'
            },
        ]

        this.$scope.attachList.forEach((attach,index)=>{
            attach.uploader=new OssFile(this.$scope,attach.uploader,{uploaderList:this.uploaderList,tag:index+1});
            attach.uploader.onSuccess=(item)=>{this.onSuccessItem('', item.fileName,item.imgSrc,index+1,item._file)};
            attach.uploader.onDelete=(item)=>{
                attach.uploader.queue=attach.uploader.queue.filter(it=>item.fileName!=it.fileName&&item.imgSrc!=it.imgSrc);
                this.uploaderList=this.uploaderList.filter(it=>attach.uploader.tag!=it.attachmentTag)
            }
        })

        this.$scope.orderUploader = new OssFile(this.$scope,this.$scope.orderUploader ,{uploaderList:[],tag:1,multiple:true});

        this.carrierOrder();
        if (this.type === "待发货" && this.contractStatus === "合同未签") {
            this.getCarAttachment(false);

        }
        if (this.contractStatus === "合同未签") {
            this.$scope.contractT = true;
        }

        $('#openDatetime').click(() => {
            $('#datetime').datetimepicker('show');
        });
        $('#openArrivalTime').click(() => {
            $('#orderRegister_breakBulk_arrivalArrivalTime').datetimepicker('show');
        });
        $('#opencontractTime').click(() => {
            if (this.$scope.deliveryBtn) { return };
            $('#orderRegister_breakBulk_contractTime').datetimepicker('show');
        });

        this.$scope.handleImgClick = (item) => { this.$scope.selectedImgSrc = item.imgSrc; }
        this.$scope.showLcoToolMdal = false;
        this.$scope.bindLocToolCode = this.bindLocToolCode;
        this.$scope.locateByTool = this.locateByTool;
        this.$scope.lt_back = () => { $('#locToolLocation').modal('hide'); }
        $('#locToolLocation').on('hidden.bs.modal', (e) => {
            this.$scope.showLcoToolMdal = false
        });

    }

    /**
     * 获取车辆附件
     */
    getCarAttachment = (isSync?: boolean) => {
        this.$scope.attachList.forEach(attach=>{
            attach.uploader.clearQueue()
        })

        this.orderService.InvoiceManagementAttachment(this.carId).then((res) => {
            if (!isSync) {
                this.uploaderList = res.data.carrierOrderAttachments;
                this.uploaderList.forEach((item) => {
                    this.showAttachment(item);
                });
            } else {
                var arr = [];
                if (this.uploaderList.length > 0) {
                    this.uploaderList.forEach((itemC) => {
                        res.data.carrierOrderAttachments.forEach((itemCar) => {
                            if (itemC.attachmentTag === itemCar.attachmentTag) {
                                itemC.attachmentId = itemCar.attachmentId;
                                itemC.attachmentName = itemCar.attachmentName;
                                itemC.attachmentPath = itemCar.attachmentPath;
                                itemC.attachmentTag = itemCar.attachmentTag;
                                return false;
                            } else {
                                arr.push(itemCar);
                            }
                        });
                    });
                } else {
                    this.uploaderList = res.data.carrierOrderAttachments;
                }
                if (arr.length > 0) {
                    let uniqueArr = this.commonService.unique(arr, "attachmentTag");
                    var concatArr = this.commonService.unique(this.uploaderList.concat(arr), 'attachmentTag');
                    this.uploaderList = this.commonService.unique(concatArr, 'attachmentTag');
                }
                this.uploaderList.forEach((item, index) => {
                    if (!item.attachmentId) {
                        this.uploaderList.splice(index, 1);
                    }
                });
                $("input[type=file]").val("");
                this.uploaderList.forEach((item) => {
                    this.showAttachment(item);
                });
            }
        });
    }


    isPassSync(item: attachmentList): any {
        return item.attachmentId
    }

    showAttachment = (item) => {
        this.$scope.attachList[Number(item.attachmentTag)-1].uploader.addByAttach(item)
        
    }

    /**
     * 获取承运单详情
     */
    carrierOrder = () => {
        /**
         * 获取承运单详情
         */
        this.orderService.invoiceManagementDetail(this.guId).then((res) => {
            this.$scope.carrierOrderData = res.data;
            this.$scope.orderList = res.data.orderList;
            this.$scope.carId = res.data.carId;
            this.$scope.remarks = res.data.remarks;

            //12.14 新增 身份证号  （未填写合同信息时，驾驶证号=身份证号；填写合同信息时，驾驶证号从合同中的驾驶证号获取）
            this.$scope.driverLicenseNumber = res.data.identity;
            
            /**
             * 判断合同信息是否为空
             */
            let contractData = res.data.contract;

            if (contractData != null) {
                if (contractData.quantityOfGoods == null) {
                    this.$scope.contractGoodsNum = 0;
                    this.sumToatlprics();

                } else {
                    this.$scope.contractGoodsNum = contractData.quantityOfGoods;
                    this.sumToatlprics();
                }
                this.contractStatus = contractData.contractStatus;
                this.$scope.contractData = contractData;
                this.$scope.contractId = contractData.id;
                this.$scope.contractNumber = contractData.contractNumber;

                this.$scope.contractGoodsNumUnit = contractData.goodsUnitEnum;
                this.$scope.contractTime = contractData.contractTime;
                this.$scope.oilCardStatus = contractData.oilCardStatusEnum;
                this.$scope.oilCardNum = contractData.oilCardNumber;
                this.$scope.contractConsignee = contractData.consignee;
                this.$scope.contractConsigneePhone = contractData.consigneePhone || "";
                this.$scope.auxiliaryTool = contractData.auxiliaryTool;
                this.$scope.engineNumber = contractData.engineNumber;
                this.$scope.frameNumber = contractData.frameNumber;
                this.$scope.trailerNumber = contractData.trailerNumber;
                this.$scope.trailerFrameNumber = contractData.trailerFrameNumber;
                this.$scope.driverLicenseNumber = contractData.driverLicenseNumber;
                this.$scope.altermatePhone = contractData.altermatePhone;
                if (contractData.totalPrice != null || contractData.totalPrice != undefined && this.$scope.carrierOrderData.payablePriceUnitEnum == this.$scope.contractGoodsNumUnit) {
                    this.$scope.totalPrice = contractData.totalPrice;
                }
                if (this.$scope.carrierOrderData.payablePriceUnitEnum != this.$scope.contractGoodsNumUnit && contractData.totalPrice == null || contractData.totalPrice == undefined) {
                    this.$scope.totalPrice = 0;
                }
                this.$scope.electronicContractNumber = contractData.electronicContractNumber;
                this.$scope.electronicContractStatus = contractData.electronicContractStatus;
                this.$scope.agreementContractNumber = contractData.agreementContractNumber;
                this.$scope.agreementContractStatus = contractData.agreementContractStatus;
                this.$scope.deliveryNumber = contractData.deliveryNumber;
                this.getEContract();
            }

            this.loadList();
            /**
             * 判断合同按钮状态
             */
            switch (this.$scope.orderList[0].status) {
                case "待发货": {
                    this.$scope.registerBackBtn = true;
                    this.$scope.registerBtnF = false;
                    this.$scope.registerBtnT = false;
                    this.$scope.saveBtn = true;
                } break;
                case "已发货": {
                    this.$scope.registerBackBtn = false;
                    this.$scope.registerBtnF = false;
                    this.$scope.registerBtnT = true;
                    this.$scope.saveBtn = true;
                } break;
                case "货已送达": {
                    this.$scope.registerBackBtn = false;
                    this.$scope.registerBtnF = false;
                    this.$scope.registerBtnT = false;
                    this.$scope.saveBtn = false;
                    this.$scope.deliveryBtn = true;
                } break;
            };

            /**
             * 电子合同货已送达禁用
             */
            if (this.$scope.orderList[0].status == "货已送达") {
                this.$scope.contractT = true;
            }
            if (this.$scope.orderList[0].status == "待发货" && this.$scope.contractData != null) {
                this.$scope.registerBackBtn = false;
                this.$scope.registerBtnF = true;
                this.$scope.registerBtnT = false;
                this.$scope.saveBtn = true;
            }
            this.type = this.$scope.orderList[0].status;

            /**
             * 承运单附件
             */
            if (this.$scope.orderList[0].status !== "待发货" || this.contractStatus !== "合同未签") {
                this.$scope.attachList.forEach(attach=>{
                    attach.uploader.clearQueue();
                })
                this.uploaderList = [];
                res.data.carrierOrderAttachments.forEach((item, index) => {
                    this.uploaderList.push(item);
                    

                    this.$scope.attachList[Number(item.attachmentTag)-1].uploader.addByAttach(item)
                });
            }
        });
    }

    /**
  * 监听野狗事件
  */
    onWilddogEcontractEvent = (event: ng.IAngularEvent, data: any) => {
        this.getEContract();

    }

    /**
    * 自动计算运费总价
    */
    sumToatlprics = () => {
        let sumtotls;
        if (this.$scope.carrierOrderData.payablePriceUnitEnum == "1" || this.$scope.carrierOrderData.payablePriceUnitEnum == "6") {
            this.$scope.totalPrice = this.$scope.carrierOrderData.payablePrice;
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "1" && this.$scope.contractGoodsNumUnit == "3") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "2" && this.$scope.contractGoodsNumUnit == "1") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "3" && this.$scope.contractGoodsNumUnit == "2") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "4" && this.$scope.contractGoodsNumUnit == "4") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "8" && this.$scope.contractGoodsNumUnit == "5") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
            /**元/台 */
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum == "10" && this.$scope.contractGoodsNumUnit == "6") {
            sumtotls = this.$scope.carrierOrderData.payablePrice * this.$scope.contractGoodsNum;
            this.$scope.totalPrice = sumtotls.toFixed(2);
        } else if (this.$scope.carrierOrderData.payablePriceUnitEnum != this.$scope.contractGoodsNumUnit) {
            this.$scope.totalPrice = 0;
        } else {
            this.$scope.totalPrice = 0;
        }
    }

    /**
     * 获取订单详情
     */
    orderDetail = (item: invoiceManagementOrder) => {
        this.$scope.orderUploader.clearQueue();
        this.$scope.selectedOrderId = item.id;
        this.$scope.forbidBindLocTool = item.status === "货已送达";
        this.$scope.orderData = item;
        /**
         * 子线路列表
         */
        this.$scope.orderChildList = item.childList;
        this.$scope.getOrderChildData = this.getOrderChildData;
        this.customerServiceOfficerList();
        this.$scope.registerDis = false;
        /**
         * 变换调度是否可用
         */
        if (window.localStorage.getItem("loginData").toString()) {
            if (JSON.parse(window.localStorage.getItem("loginData").toString()).id != item.customerServiceId || this.$scope.orderList[0].status != "待发货") {
                this.$scope.registerDis = true;
            };
        };
        /**
       

        /**
         * 订单附件
         */
        this.orderAttachList = [];
        let orderArr = item.orderAttachments;
        orderArr.forEach((itemO, index) => {
            this.orderAttachList.push(itemO);
            // this.commonService.showFileItem(itemO, this.$scope.orderUploader);
            this.$scope.orderUploader.addByAttach(itemO)
        });

        /**
         * 回单状态
         */
        this.feeService.receiptStatus(this.$scope.orderData.id).then((res) => {
            if (res.data.receiptStatus == "0") {
                this.$scope.receiptType = "2";
            } else {
                this.$scope.receiptType = res.data.receiptStatus;
            };
        });

        this.$scope.changeDispatch = this.changeDispatch;
        this.$scope.SaveReceipts = this.SaveReceipts;
        /**
         * 查看订单是否已经绑定到定位器
         */
        this.$scope.orderBinded = false;
        this.locationService.checkOrderBinded(item.id,!(item.status === "货已送达")).then(res => {
            if (res.data.extData) {
                this.$scope.orderBinded = true;
            }
        })
        this.$scope.bindFailed = false;
        this.$scope.bindSucced = false;
        this.$scope.locToolCode = '';

    }

    /**
     * 获取子单数据
     */
    getOrderChildData = (item: invoiceManagementOrderChild) => {
        this.$scope.orderChildData = item;
    };

    /**
     * 客服专员
     */
    customerServiceOfficerList = () => {
        this.employeeService.getbytype("4", 0, -1).then((res) => {
            this.$scope.customerServiceOfficerList = res.data.data;
            this.$scope.customerServiceOfficerId = String(this.$scope.orderData.customerServiceId);
        });
    }

    /**
     * 变换调度员
     */
    changeDispatch = () => {
        this.orderService.editOfficer(this.guId, "", "", "", this.$scope.customerServiceOfficerId, $("#orderRegister_breakBulk_detail_customerServiceOfficer option:selected").text()).then((res) => {
            this.$state.go("app.order.orderRegisterList", { name: "argument" });
        });
    }

    /**
     * 下拉列表(订单状态不为“货已送达”)
     */
    loadList = () => {
        this.$scope.goodsNumUnitList = this.valueService.getGoodQuantityUnitList().data;
        if (this.type != "货已送达") {
            this.$scope.receiptStatusList = this.valueService.getReceiptStatusList().data.slice(0, 2);
        }
        else {
            this.$scope.receiptStatusList = this.valueService.getReceiptStatusList().data;
        }
        this.$scope.oilCardStatusList = this.valueService.getOilCCardStatusList().data;
    }
    /**
     * 保存回单状态
     */
    SaveReceipts = () => {
        this.feeService.receipts(true, this.$scope.orderData.id, this.$scope.receiptType, "", [], "1").then((res) => {////默认的结算单据状态为 1：无结算单据
            $('#detail').modal('hide')
        }, (rej) => { })
    }

    /**
     * 定位事件
     */
    location = (carId: string, driverPhone: string) => {

        this.$scope.carId = carId;
        var carId = carId;
        var driverPhone = driverPhone;

        this.$scope.carCode = this.$scope.carrierOrderData.carCode;
        this.$scope.phoneNumber = driverPhone;


        this.locationService.getHistoryLocation(carId, true).then((resq) => {
            this.$scope.areaS = resq.data.area;
            this.$scope.creationTimeS = resq.data.creationTime;
        }, (rel) => { console.log(rel); });

        this.locationService.getLocationState(carId, true).then((res) => {
            if (res.data.isRegister == true) {
                this.$scope.isdisabled1 = true;
                this.$scope.isdisabled2 = false;
            } else {
                this.$scope.isdisabled1 = false;
                this.$scope.isdisabled2 = true;
            }

        }, (rej) => {

            this.$scope.isdisabled1 = true;
            this.$scope.isdisabled2 = true;
        }
        )
    }

    /**
     * 已发货
     */
    delivered = () => {
        this.orderService.editOrderStatusByCarrierOrderId(this.guId, this.$scope.remarks, "6", "", "").then((res) => {
            this.$scope.registerBtnF = false;
            this.$scope.registerBtnT = true;
            this.$ngBootbox.alert("保存成功")
        });
    }

    /**
     * 退回派车
     */
    returnOrderC = () => {
        this.$ngBootbox.confirm('确定退回派车吗？').then(() => {
            this.orderService.editOrderStatusByCarrierOrderId(this.guId, this.$scope.remarks, "4", "", "").then((res) => {
                this.$state.go("app.order.orderRegisterList", { name: "argument" });//跳转发货登记列表
            });
        }, () => { return; });
    }

    /**
     * 清除货已送达时间
     */
    clearTime = () => {
        $('#orderRegister_breakBulk_arrivalArrivalTime').val("");
    }

    /**
     * 货已送达
     */
    Save = () => {
        this.orderService.editOrderStatusByCarrierOrderId(this.guId, this.$scope.remarks, "7", "", this.$scope.arrivalTime).then((res) => {
            $('#arrival').modal('hide')//关闭弹窗
            this.$state.go("app.order.orderRegisterList", { name: "argument" });//跳转发货单受理
        });
    }
    /**
     * 附件是否可以下载
     */
    isUpLoad = () => {
        this.uploaderList.forEach((item, index) => {
            switch (item.attachmentTag) {
                case "1": this.$scope.driverUploader.isLoad = false;
                    break;
                case "2": this.$scope.trailerUploader.isLoad = false;
                    break;
                case "3": this.$scope.travelUploader.isLoad = false;
                    break;
                case "4": this.$scope.idCardUploader.isLoad = false;
                    break;
                case "5": this.$scope.carPicUploader.isLoad = false;
                    break;
                case "6": this.$scope.roadTransportCardUploader.isLoad = false;
                    break;
                case "7": this.$scope.roadTransportLicenseUploader.isLoad = false;
                    break;
                case "8": this.$scope.occupationalLicenseUploader.isLoad = false;
                    break;
                case "9": this.$scope.weightNoteUploader.isLoad = false;
                    break;
            }
        });
    }

    /**
   * 生成合同号
   */
    contractSave = () => {
        this.$scope.saveDis = true;
        var attachmentArr = [];
        this.uploaderList.forEach((item, index) => {
            if (item.attachmentTag) {
                attachmentArr.push([item.attachmentId, item.attachmentName, item.attachmentPath, item.attachmentTag]);
            }
        });

        if (this.$scope.carrierOrderData.contract == null) {
            this.orderService.addContract(
                this.guId,
                this.$scope.contractId,
                this.$scope.contractNumber,
                this.$scope.contractGoodsNum,
                this.$scope.contractGoodsNumUnit,
                this.$scope.contractTime,
                this.$scope.contractConsignee,
                this.$scope.contractConsigneePhone,
                this.$scope.oilCardStatus,
                this.$scope.oilCardNum,
                this.$scope.auxiliaryTool,
                this.$scope.engineNumber,
                this.$scope.frameNumber,
                this.$scope.trailerNumber,
                this.$scope.trailerFrameNumber,
                this.$scope.driverLicenseNumber,
                this.$scope.altermatePhone,
                attachmentArr,
                this.$scope.remarks,
                this.$scope.receiptState,
                this.$scope.isAutoCreate,
                this.$scope.deliveryNumber,
                this.$scope.totalPrice
            ).then((res) => {
                this.contractId = res.data.extData;
                this.$ngBootbox.alert("保存成功");
                this.$scope.saveDis = false;
                if (this.$scope.registerBtnT == true) {
                    this.$scope.registerBtnF = false;
                } else {
                    this.$scope.registerBtnF = true;
                    this.$scope.registerBackBtn = false;
                }
                // this.isUpLoad();
                this.$state.go("app.order.orderRegisterBulk", { id: this.guId, contractStatus: "合同已签", name: "RegisterBreak", type: this.type, carId: this.carId });
                this.carrierOrder();
            }, (rej) => { this.$scope.saveDis = false; });
        }
        else if (this.$scope.carrierOrderData.contract != null || !this.$scope.registerBackBtn) {
            this.orderService.editContract(
                this.$scope.carrierOrderData.contract.id,
                this.guId,
                this.contractId,
                this.$scope.contractNumber,
                this.$scope.contractGoodsNum,
                this.$scope.contractGoodsNumUnit,
                this.$scope.contractTime,
                this.$scope.contractConsignee,
                this.$scope.contractConsigneePhone,
                this.$scope.oilCardStatus,
                this.$scope.oilCardNum,
                this.$scope.auxiliaryTool,
                this.$scope.engineNumber,
                this.$scope.frameNumber,
                this.$scope.trailerNumber,
                this.$scope.trailerFrameNumber,
                this.$scope.driverLicenseNumber,
                this.$scope.altermatePhone,
                attachmentArr,
                this.$scope.remarks,
                this.$scope.receiptState,
                this.$scope.isAutoCreate,
                this.$scope.deliveryNumber,
                this.$scope.totalPrice
            ).then((res) => {
                this.$scope.saveDis = false;
                this.$ngBootbox.alert("保存成功");
                if (this.$scope.registerBtnT == true) {
                    this.$scope.registerBtnF = false;
                } else {
                    this.$scope.registerBtnF = true;
                    this.$scope.registerBackBtn = false;
                }
                // this.isUpLoad();
                this.$state.go("app.order.orderRegisterBulk", { id: this.guId, contractStatus: "合同已签", name: "RegisterBreak", type: this.type, carId: this.carId });
                this.carrierOrder();
            }, (rej) => { this.$scope.saveDis = false; });
        }

    }

    /**
     * 确定事件
     */
    registerSave = () => {
        if (!$("#registerForm").valid()) { return; }
        if (!this.$scope.contractFrom.$valid) { return }

        if (this.$scope.contractNumber == "" || this.$scope.contractNumber == undefined || this.$scope.contractNumber == null) {
            this.$ngBootbox.confirm('您未填写合同号，是否需要系统自动生成合同号并保存？').then(() => {
                this.$scope.isAutoCreate = true;
                this.contractSave();
                // $("#orderRegister_breakBulk_contractNumber").removeClass("ng-invalid");
                // $("#orderRegister_breakBulk_contractNumber").addClass("ng-valid");
            }, () => {
                this.$scope.saveDis = false; return;
            });
        } else {
            this.$ngBootbox.confirm('确定保存数据吗？').then(() => {
                this.$scope.isAutoCreate = false;
                this.contractSave();
            });
        }


    }

    /**
   * 输入纯数字验证
   */
    patte = (contractNumber) => {
        let pattern = /^[0-9]+$/;
        if (pattern.test(contractNumber) == false) {
            $("#orderRegister_breakBulk_contractNumber").addClass("ng-invalid");
            $("#orderRegister_breakBulk_contractNumber").removeClass("ng-valid");
            $("#orderRegister_breakBulk_registerSave").attr("disabled", "disabled");
        } else {
            $("#orderRegister_breakBulk_contractNumber").removeClass("ng-invalid");
            $("#orderRegister_breakBulk_contractNumber").addClass("ng-valid");
            $("#orderRegister_breakBulk_registerSave").removeAttr("disabled");
        }
    }

    /**
        * 清空合同信息
        */
    clearContractF = () => {
        this.$scope.contractNumber = "";

    }
    /**
    * 创建电子合同
    */
    CreatEcontract = () => {
        this.orderService.AddEContract(this.guId).then((res) => {
            this.$ngBootbox.alert("创建电子合同成功！");
            this.$scope.electronicContractNumber = res.data.extData;
            this.$scope.electronicContractStatus = "1";
            this.$scope.isContractO = false;
            this.showEContract();
        });
    }
    /**
        * 查看电子合同详情
        */
    EContractDetail = () => {
        if (this.$scope.electronicContractNumber != null || this.$scope.electronicContractStatus != "6" && this.$scope.electronicContractStatus != null) {
            this.showEContract();
        } else {
            $("#Econtract").modal('show');
            this.$scope.isContractO = true;
            this.$scope.contractImgA = "";
            this.$scope.contractImgB = "";
            this.$scope.contractImgC = "";
        }
    }

    /**
* 获取电子合同最新状态
*/
    getEContract = () => {
        this.orderService.getEContract(this.guId).then((res) => {
            this.$scope.contractId = res.data.contractId;
            this.$scope.electronicContractNumber = res.data.electronicContractNumber;
            this.$scope.electronicContractStatus = res.data.electronicContractStatus;
            this.$scope.agreementContractNumber = res.data.agreementContractNumber;
            this.$scope.agreementContractStatus = res.data.agreementContractStatus;
            //合同
            if (this.$scope.electronicContractStatus == "1" || this.$scope.electronicContractStatus == "3") {//已创建合同/司机退回
                this.$scope.waitSign = false;
                this.$scope.kfSeal = false;
                this.$scope.isSend = true;
                this.$scope.Ecancel = true;
                this.$scope.applyAgreement = false;
                this.$scope.isContractO = false;
            }
            if (this.$scope.electronicContractStatus == "2") {//发送合同
                this.$scope.waitSign = true;
                this.$scope.kfSeal = false;
                this.$scope.isSend = false;
                this.$scope.Ecancel = false;
                this.$scope.applyAgreement = false;
                this.$scope.isContractO = false;
            }
            if (this.$scope.electronicContractStatus == "4") {//司机签字
                this.$scope.waitSign = false;
                this.$scope.kfSeal = true;
                this.$scope.isSend = false;
                this.$scope.Ecancel = true;
                this.$scope.applyAgreement = false;
                this.$scope.isContractO = false;

                this.orderService.EContractDetail(this.$scope.electronicContractNumber).then((res) => {
                    this.$scope.contractImgA = res.data.imgList[0] + '?t=' + Math.random();
                    this.$scope.contractImgB = res.data.imgList[1] + '?t=' + Math.random();
                    this.$scope.contractImgC = res.data.imgList[2] + '?t=' + Math.random();

                }, (rej) => { });
            }
            if (this.$scope.electronicContractStatus == "5") {//客服签章
                this.$scope.waitSign = false;
                this.$scope.kfSeal = false;
                this.$scope.isSend = false;
                this.$scope.Ecancel = false;
                this.$scope.applyAgreement = true;
                this.$scope.isContractO = false;

            }
            if (this.$scope.electronicContractStatus == "6") {//客服撤销
                this.$scope.waitSign = false;
                this.$scope.kfSeal = false;
                this.$scope.isSend = false;
                this.$scope.Ecancel = false;
                this.$scope.applyAgreement = false;
                this.$scope.isContractO = true;
            }
            if (this.$scope.agreementContractNumber != null) {
                this.$scope.isAgreementF = true;
            }
            //补充协议
            if (this.$scope.agreementContractStatus == "1" || this.$scope.agreementContractStatus == "3") {//已创建合同/司机退回
                this.$scope.waitASign = false;
                this.$scope.kfASeal = false;
                this.$scope.isASend = true;
                this.$scope.EAcancel = true;
                this.$scope.applyAgreement = false;
            }
            if (this.$scope.agreementContractStatus == "2") {//发送合同
                this.$scope.waitASign = true;
                this.$scope.kfASeal = false;
                this.$scope.isASend = false;
                this.$scope.EAcancel = false;
                this.$scope.applyAgreement = false;
            }
            if (this.$scope.agreementContractStatus == "4") {//司机签字
                this.$scope.waitASign = false;
                this.$scope.kfASeal = true;
                this.$scope.isASend = false;
                this.$scope.EAcancel = true;
                this.$scope.applyAgreement = false;

                this.orderService.EContractDetail(this.$scope.agreementContractNumber).then((res) => {
                    this.$scope.agreementImgA = res.data.imgList[0] + '?t=' + Math.random();
                    this.$scope.agreementImgB = res.data.imgList[1] + '?t=' + Math.random();
                    this.$scope.agreementImgC = res.data.imgList[2] + '?t=' + Math.random();

                }, (rej) => { });
            }
            if (this.$scope.agreementContractStatus == "5") {//客服签章
                this.$scope.waitASign = false;
                this.$scope.kfASeal = false;
                this.$scope.isASend = false;
                this.$scope.EAcancel = false;
                this.$scope.applyAgreement = false;

            }
            if (this.$scope.agreementContractStatus == "6") {//客服撤销
                this.$scope.waitASign = false;
                this.$scope.kfASeal = false;
                this.$scope.isASend = false;
                this.$scope.EAcancel = false;
                this.$scope.applyAgreement = false;
            }
        }, (rej) => { });


    }

    /**
     * 弹出电子合同详情
     */
    showEContract = () => {
        this.getEContract();
        if (this.$scope.electronicContractNumber != null) {
            this.orderService.EContractDetail(this.$scope.electronicContractNumber).then((res) => {
                this.$scope.contractImgA = res.data.imgList[0] + '?t=' + Math.random();
                this.$scope.contractImgB = res.data.imgList[1] + '?t=' + Math.random();
                this.$scope.contractImgC = res.data.imgList[2] + '?t=' + Math.random();
                $('#Econtract').modal('show');
            }, (rej) => { });
        }
    }

    /**
     * 发送合同
     */
    contractSend = () => {
        this.$ngBootbox.confirm('是否发送合同到来货拉？').then(() => {
            this.orderService.UpdateEContractStatus(this.$scope.contractId, "1", "2", this.$scope.carId).then((res) => {
                this.$ngBootbox.alert("电子合同已发送！");
                this.$scope.electronicContractStatus = "2";
                this.getEContract();
            });
        });
    }

    /**
    * 撤销合同
    */
    contractRescind = () => {
        this.orderService.UpdateEContractStatus(this.$scope.contractId, "1", "6", this.$scope.carId).then((res) => {
            this.$ngBootbox.alert("电子合同已撤销！");
            this.$scope.electronicContractStatus = "6";
            this.getEContract();
            $('#Econtract').modal('hide');
            this.$scope.isSend = false;
            this.$scope.Ecancel = false;
        });
    }

    /**
   * 客服签章
   */
    contractSeal = () => {
        this.$ngBootbox.confirm('是否确认签章？').then(() => {
            this.orderService.UpdateEContractStatus(this.$scope.contractId, "1", "5", this.$scope.carId).then((res) => {
                this.$ngBootbox.alert("电子合同已签章！");
                this.$scope.electronicContractStatus = "5";
                this.getEContract();
                this.orderService.EContractDetail(this.$scope.electronicContractNumber).then((res) => {
                    this.$scope.contractImgA = res.data.imgList[0] + '?t=' + Math.random();
                    this.$scope.contractImgB = res.data.imgList[1] + '?t=' + Math.random();
                    this.$scope.contractImgC = res.data.imgList[2] + '?t=' + Math.random();

                }, (rej) => { });
            });
        });
    }


    /**
     * 申请补充协议
     */
    isapplyAgreement = () => {

        if (this.$scope.agreementContractNumber != null) {
            this.showEAgreement();
        } else {
            this.$ngBootbox.confirm('是否申请补充协议？').then(() => {
                this.orderService.AddAgreementEContract(this.guId).then((res) => {
                    this.$ngBootbox.alert("申请补充协议成功！");
                    this.$scope.agreementContractNumber = res.data.extData;
                    this.$scope.applyAgreement = false;
                    this.showEAgreement();
                }, (rej) => { });
            });
        }

    }

    /**
    * 切换TAB补充协议
    */
    showEAgreement = () => {
        this.getEContract();
        this.$scope.isContractO = false;
        this.$scope.isAgreementO = true;
        if ($('.tab-pane:eq(0)').attr("class").search("active") != -1 && $('.uib-tab:eq(0)').attr("class").search("active") != -1) {
            $('.tab-pane:eq(0)').removeClass("active");
            $('.tab-pane:eq(1)').addClass("active");
            $('.uib-tab:eq(0)').removeClass("active");
            $('.uib-tab:eq(1)').addClass("active");
        }
        this.orderService.EContractDetail(this.$scope.agreementContractNumber).then((res) => {
            this.$scope.agreementImgA = res.data.imgList[0] + '?t=' + Math.random();
            this.$scope.agreementImgB = res.data.imgList[1] + '?t=' + Math.random();
            this.$scope.agreementImgC = res.data.imgList[2] + '?t=' + Math.random();

            this.$scope.agreementContractStatus = "1";

        }, (rej) => { });
    }

    /**
 * 发送补充协议
 */
    AgreementSend = () => {
        this.$ngBootbox.confirm('是否发送补充协议到来货拉？').then(() => {
            this.orderService.UpdateEContractStatus(this.$scope.contractId, "2", "2", this.$scope.carId).then((res) => {
                this.$ngBootbox.alert("补充协议已发送！");
                this.$scope.agreementContractStatus = "2";
                this.getEContract();
            });
        });
    }

    /**
    * 撤销补充协议
    */
    AgreementRescind = () => {
        this.orderService.UpdateEContractStatus(this.$scope.contractId, "2", "6", this.$scope.carId).then((res) => {
            this.$ngBootbox.alert("补充协议已撤销！");
            this.$scope.agreementContractStatus = "6";
            this.getEContract();
            $('#Econtract').modal('hide');
            this.$scope.isAgreementF = false;
            this.$scope.isASend = false;
            this.$scope.EAcancel = false;
            if ($('.tab-pane:eq(1)').attr("class").search("active") != -1 && $('.uib-tab:eq(1)').attr("class").search("active") != -1) {
                $('.tab-pane:eq(1)').removeClass("active");
                $('.tab-pane:eq(0)').addClass("active");
                $('.uib-tab:eq(1)').removeClass("active");
                $('.uib-tab:eq(0)').addClass("active");
            }
        });
    }

    /**
     * 客服签章补充协议
     */
    AgreementSeal = () => {
        this.$ngBootbox.confirm('是否确认签章？').then(() => {
            this.orderService.UpdateEContractStatus(this.$scope.contractId, "2", "5", this.$scope.carId).then((res) => {
                this.$ngBootbox.alert("补充协议已签章！");
                this.$scope.agreementContractStatus = "5";
                this.getEContract();
                this.orderService.EContractDetail(this.$scope.agreementContractNumber).then((res) => {
                    this.$scope.agreementImgA = res.data.imgList[0] + '?t=' + Math.random();
                    this.$scope.agreementImgB = res.data.imgList[1] + '?t=' + Math.random();
                    this.$scope.agreementImgC = res.data.imgList[2] + '?t=' + Math.random();

                }, (rej) => { });
            });
        });
    }

    /**
     * 点击显示电子合同
     */
    ContractO = () => {
        if ($('.tab-pane:eq(1)').attr("class").search("active") != -1 && $('.uib-tab:eq(1)').attr("class").search("active") != -1) {
            $('.tab-pane:eq(1)').removeClass("active");
            $('.tab-pane:eq(0)').addClass("active");
            $('.uib-tab:eq(1)').removeClass("active");
            $('.uib-tab:eq(0)').addClass("active");
        }
        if (this.$scope.electronicContractNumber != null) {
            this.orderService.EContractDetail(this.$scope.electronicContractNumber).then((res) => {
                this.$scope.contractImgA = res.data.imgList[0] + '?t=' + Math.random();
                this.$scope.contractImgB = res.data.imgList[1] + '?t=' + Math.random();
                this.$scope.contractImgC = res.data.imgList[2] + '?t=' + Math.random();
            }, (rej) => { });
            this.$scope.isAgreementO = false;
        }
    }
    /**
     * 点击显示补充协议
     */
    AgreementO = () => {
        this.$scope.isContractO = false;
        this.$scope.isAgreementO = true;
        this.showEAgreement();
    }
    /**
     * 关闭合同信息弹窗
     */
    EAclose = () => {
        $('#Econtract').modal('hide');
        this.$scope.isContractO = true;
        this.$scope.isAgreementO = false;
    }
    /**
     * 同步车厂
     */
    syncAttachment = () => {
        this.getCarAttachment(true);
    }

    /**
     * 选择上传文件后
     */
    onSuccessItem(fileId: string, fileName: string, filePath: string, tag: number, file?: any): void {
        file.fileId = filePath;
        let attachment = {
            attachmentId: fileId,
            attachmentName: fileName,
            attachmentPath: filePath,
            attachmentTag: tag.toString()
        };
        this.uploaderList.push(attachment);
    }

    /**
     * 删除上传的附件
     */
    onDelete = (item: any, num: number) => {
        var types = item.types || num;
        this.commonService.onDelete(item, this.uploaderList);
        switch (types) {
            case 1: this.$scope.driverUploader.isLoad = true;
                break;
            case 2: this.$scope.trailerUploader.isLoad = true;
                break;
            case 3: this.$scope.travelUploader.isLoad = true;
                break;
            case 4: this.$scope.idCardUploader.isLoad = true;
                break;
            case 5: this.$scope.carPicUploader.isLoad = true;
                break;
            case 6: this.$scope.roadTransportCardUploader.isLoad = true;
                break;
            case 7: this.$scope.roadTransportLicenseUploader.isLoad = true;
                break;
            case 8: this.$scope.occupationalLicenseUploader.isLoad = true;
                break;
            case 9: this.$scope.weightNoteUploader.isLoad = true;
                break;
        }
    }


    //取消返回
    skipManage = () => {
        this.$state.go("app.order.orderRegisterList", { name: "argument" })
    }

    bindLocToolCode = () => {

        this.locationService.bindToLocTool(this.$scope.selectedOrderId, this.$scope.locToolCode).then(res => {
            if (res.data.extData) {
                this.$scope.orderBinded = true;
                this.$scope.bindSucced = true;
                this.$scope.bindFailed = false;
            } else {
                this.$scope.bindFailed = true;
                this.$scope.bindSucced = false
                this.$ngBootbox.alert(res.data.errorMsg);
            }
        })
    }
    locateByTool = () => {
        this.$scope.showLcoToolMdal = true;
    }
}
angular.module("tms").controller("orderRegisterBreakController", ["$scope", "routeService", "locationService", "orderService",
    "valueService", "feeService", "employeeService", "$stateParams", "$http", "$state", "$ngBootbox", "$location", "commonService","ossUploaderService", OrderRegisterBreakController]);